﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using ThreeTeams.API.Application.Command.ShelvesCommand;
using ThreeTeams.API.DTOs;
using ThreeTeams.ErrorCode;

namespace ThreeTeams.API.Controllers
{
    [Route("api/[controller]/[action]")]
    public class ShelvesController : Controller
    {
        IMediator mediator;

        public ShelvesController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        [HttpPost]
        public Task<ApiResult<int>> AddShelves([FromBody]AddShelvesCommand request)
        { 
            return mediator.Send(request);
        }
        [HttpPut]
        public Task<ApiResult<int>> UpdateShelves([FromBody] UpdateShelvesCommand request)
        {
            return mediator.Send(request);
        }

        [HttpDelete]
        public Task<ApiResult<int>> DeleteShelves([FromBody] DeleteShelvesCommand request)
        {
            return mediator.Send(request);
        }

        [HttpGet]
        public Task<ApiPaging<ShelvesDto>> QueryShelves([FromQuery] QueryShelvesCommand request)
        {
            return mediator.Send(request);
        }


        [HttpGet]
        public Task<ApiResult<ShelvesDto>> GetShelvesById([FromQuery] int id)
        {
            return mediator.Send(new GetShelvesByIdCommand { Id = id });
        }
    }
}
